/*83856*/
<template>
  <div>
    <el-menu
        default-active="/"
        class="el-menu-vertical-demo"
        router
        :collapse="isCollapse"
        @open="handleOpen"
        @close="handleClose"
        @select="goSelect"
    >
      <el-menu-item index="/">
        <el-icon>
          <icon-menu/>
        </el-icon>
        <span>首页</span>
      </el-menu-item>
      <el-sub-menu v-for="n in navList" :index="n.clmid">
        <template #title>
          <el-icon>
            <location/>
          </el-icon>
          <span>{{ n.clmname }}</span>
        </template>
        <el-menu-item-group>
          <el-menu-item :index="c.clmurl" v-for="c in n.childs">{{ c.clmname }}</el-menu-item>
        </el-menu-item-group>
      </el-sub-menu>
    </el-menu>
  </div>
</template>

<script lang="ts" setup>
import {ref} from 'vue'
import {
  Document,
  Menu as IconMenu,
  Location,
  Setting,
} from '@element-plus/icons-vue'
import {useRouter} from 'vue-router'
import navs from "../../api/Navs"

const router = useRouter();

const navList = ref(navs)

const isCollapse = ref(false)
const handleOpen = (key: string, keyPath: string[]) => {
  // console.log(key, keyPath)
}
const handleClose = (key: string, keyPath: string[]) => {
  // console.log(key, keyPath)
}

const goSelect = (index: string, indexPath: string) => {
  console.log('indexPath', indexPath[0])
  // router.push({
  //   path: indexPath[0], query: {}
  // })

}
</script>

<style scoped lang="scss">
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}

</style>